#pragma once

class BinaryStream
{
public:
	BinaryStream();
	~BinaryStream();

	void Attach(void* ptr, uint32_t size);
	void Detach(void*& ptr, uint32_t& size);
	void GetRawData(void*& ptr, uint32_t& size) const;

	uint32_t Read(void*& p, uint32_t count);
	uint32_t Write(const void *p, uint32_t count);
	uint32_t Peek(void*& p, uint32_t count) const;
	uint32_t RemoveLeft(uint32_t count);
	uint32_t RemoveRight(uint32_t count);
	void Clear();
	uint32_t GetLength() const;

private:
	bool DuplicateRawData(uint32_t new_size, uint32_t copy_offset, uint32_t copy_size);

private:
	struct
	{
		void* ptr_;
		uint32_t size_;
	} rawData_;

	uint32_t partitionSize_;
};
